﻿@model Sharp.Web.Models.OrgIndexModel
@{

    var x = Html.X();
}
@(
 x.TreePanel()
    .UseArrows(false).AutoScroll(true).Mode(TreePanelMode.Local).RootVisible(false).Border(false)
    .Animate(false).FolderSort(false).SortableColumns(false)
    .TopBar(x.Toolbar().Items(
    x.Button().Text("浏览").OnClientClick("App.Grid.OnModuleOperation(this,'" + Url.Action("Details") + "');"),
    x.Button().Text("新增").OnClientClick("App.Grid.OnModuleOperation(this,'" + Url.Action("Create") + "',{ShowOnly:true});"),
    x.Button().Text("修改").OnClientClick("App.Grid.OnModuleOperation(this,'" + Url.Action("Edit") + "');"),
    x.Button().Text("删除").OnClientClick("App.Grid.OnModuleOperation(this,'" + Url.Action("Delete") + "',{IsAjax:true});"),
    new ToolbarFill(),
    x.TextField().Width(300).FieldLabel("搜索").LabelWidth(50)
        .Triggers(
            x.FieldTrigger().Icon(TriggerIcon.Clear).HideTrigger(true),
            x.FieldTrigger().Icon(TriggerIcon.Search)
        )
            .Listeners(ls => { ls.TriggerClick.Fn = "App.Main.searchFieldTriggerClick"; })
    ))
    .SelectionModel(x.CheckboxSelectionModel()).RemoteJson(true)
    .RemoteMoveUrl(Url.Action("MoveOrSort"))
    .ColumnModel(
        x.ColumnFor(c => c.Code),
        x.TreeColumn().Width(200).DataIndex("text").Text("名称"),
        
        x.ColumnFor(c => c.OrgPath),
        x.ColumnFor(c => c.MaxHeadcount),
        x.ColumnFor(c => c.CurrentHeadcount)
    )
    .Store(x.TreeStore()
        .Proxy(x.AjaxProxy().Json(true).Url(Url.Action("GetTreeData")).Reader(x.JsonReader()))
        .Root(x.Node().NodeID("Root"))
    )

    .Listeners(l =>
    {

    })
        .View(x.TreeView().Plugins(x.TreeViewDragDrop().AllowLeafDrop(true)).Listeners(l => l.Drop.Fn = "App.Grid.dropItem"))
   
)